package com.huike.web.controller.report;


import cn.hutool.crypto.SecureUtil;
import com.huike.common.utils.SecurityUtils;
import com.huike.report.domain.vo.IndexTodayInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;

    /**
     * 今日简报 -接口开发
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        //准备业务需要的参数
        String username = SecurityUtils.getUsername();
        String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        IndexTodayInfoVO indexTodayInfoVO = reportService.getTodayInfo(username, today);
        return AjaxResult.success(indexTodayInfoVO);
    }
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(String  beginCreateTime,String  endCreateTime){
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }


}